//存放公共脚本


//验证登录
export function identity(){
	let logged = uni.getStorageSync('isLogin');
	let sessionKey = uni.getStorageSync('sessionKey');
	if (isEmpty(logged)) return false;
	if (logged.toString() == 'false') return false;
	if (isEmpty(sessionKey)) return false;
	return true;
}

//验证无效值空值等
function isEmpty(val) {
	if (typeof(val) == 'undefined') return true;
	if (val == undefined) return true;
	if (val == null) return true;
	val = val.toString();
	if (val == '') return true;
	if (val.length <= 0) return true;
	return false;
}

//传入url 根据参数名获取对应值
function getQueryVariable(url, variable) {
	var query = (url.indexOf('?') > 0) ? url.split('?')[1] : url;
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return '';
}